/**
 * 单位转换
 * @param converWeight  转换成的重量单位
 * @param weight 被转换重量
 * @param weightUnit 被转换重量单位
 */
export function ConversionRatioRetail(converWeight: string, weight: any, weightUnit: any): number {
    let retailNum = (parseInt(weight) || 0);
    let retailWeight = 0;
    // 等于 克
    if (converWeight == '101') {
        // 克
        if (weightUnit == '101') {
            retailWeight = retailNum
        }
        // 千克
        if (weightUnit == '102') {
            retailWeight = retailNum * 1000
        }
        // 斤
        if (weightUnit == '103') {
            retailWeight = retailNum * 500
        }
        // 公斤
        if (weightUnit == '104') {
            retailWeight = retailNum * 1000
        }
    }
    // 等于 千克
    if (converWeight == '102') {
        // 克
        if (weightUnit == '101') {
            retailWeight = retailNum / 1000
        }
        // 千克
        if (weightUnit == '102') {
            retailWeight = retailNum
        }
        // 斤
        if (weightUnit == '103') {
            retailWeight = retailNum / 2
        }
        // 公斤
        if (weightUnit == '104') {
            retailWeight = retailNum
        }
    }
    // 等于 斤
    if (converWeight == '103') {
        // 克
        if (weightUnit == '101') {
            retailWeight = retailNum / 500
        }
        // 千克
        if (weightUnit == '102') {
            retailWeight = retailNum * 2
        }
        // 斤
        if (weightUnit == '103') {
            retailWeight = retailNum
        }
        // 公斤
        if (weightUnit == '104') {
            retailWeight = retailNum * 2
        }

    }
    // 等于 公斤
    if (converWeight == '104') {
        // 克
        if (weightUnit == '101') {
            retailWeight = retailNum / 1000
        }
        // 千克
        if (weightUnit == '102') {
            retailWeight = retailNum
        }
        // 斤
        if (weightUnit == '103') {
            retailWeight = retailNum / 2
        }
        // 公斤
        if (weightUnit == '104') {
            retailWeight = retailNum
        }
    }
    return retailWeight;
}


const numberToChinese: { [key: number]: string } = {
    0: '零',
    1: '一',
    2: '二',
    3: '三',
    4: '四',
    5: '五',
    6: '六',
    7: '七',
    8: '八',
    9: '九',
}


export function convertToChinese(num: number): string {
    return numberToChinese[num];
}